#include "GhostSelect.h"

GhostSelect::GhostSelect()
{
}

void GhostSelect::initalize(EGhostColor color, Vec2 position, float scale, int value)
{
	m_value = value;

	GhostObject::initalize(color, position, scale);
	initValue();
}

void GhostSelect::initValue()
{
	float newWidthGhost = m_body->getContentSize().width*m_scale;
	float newHeightGhost = m_body->getContentSize().height*m_scale;

	Button* btnValue = Button::create();
	btnValue->loadTextures("messagebox.png", "messagebox.png");
	btnValue->setTitleText(String::createWithFormat("%d", m_value)->getCString());
	btnValue->setTitleColor(Color3B::BLACK);
	btnValue->setScale(m_scale);
	btnValue->setTitleFontSize((btnValue->getContentSize().height * m_scale) / 3);
	btnValue->setPosition(Vec2(m_body->getPosition().x, m_body->getPosition().y + newHeightGhost));
	btnValue->runAction(RepeatForever::create(Sequence::create(ScaleTo::create(0.7f, 1.5f), ScaleTo::create(1.0f, 1.2f), NULL)));

	btnValue->addClickEventListener(CC_CALLBACK_1(GhostSelect::tapValue, this));

	this->addChild(btnValue);
}

void GhostSelect::tapValue(cocos2d::Ref *pSender)
{
	//GamePlayConfig::GetInstance()->m_selectNumber = atoi(value.c_str());
}
